﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MostRecentlyUsed;
using MostRecentlyUsed.Models.EventArguments;

namespace MostRecentlyUsedTests
{
    [TestClass]
    public class ItemSelectedTests
    {
        [TestMethod]
        public void ItemSelectedWithDisplayName()
        {
            var dbConnections = new DatabaseConnections();

            var itemSelected = new SelectedConnectionString("User Id=Andy;Password=MyWord;Another=Yes", "System.Data", dbConnections.ItemsToReplace, "My Display Name");

            Assert.AreEqual("My Display Name", itemSelected.DisplayName);
        }

        [TestMethod]
        public void ItemSelectedWIthoutDisplayName()
        {
            var dbConnections = new DatabaseConnections();

            var itemSelected = new SelectedConnectionString("User Id=Andy;Password=MyWord;Another=Yes", "System.Data", dbConnections.ItemsToReplace);

            Assert.AreEqual("User Id=Andy;Another=Yes", itemSelected.DisplayName);

            itemSelected = new SelectedConnectionString("User Id=Andy;Another=Yes;Password=MyWord", "System.Data", dbConnections.ItemsToReplace);

            Assert.AreEqual("User Id=Andy;Another=Yes;", itemSelected.DisplayName);
        }
    }
}
